define(['./HandPlugin', 
	'../../BaseToolHandler',
	'../../Environment'], function(HandPlugin, BaseToolHandler, Environment) {
	'use strict';
	HandPlugin.factory('HandToolHandler', ['ToolHandlerManager', function (ToolHandlerManager) {
	 	var _bMovePage = false,
        _oldPosY = 0,
        _oldPosX = 0;	

        var _self = new BaseToolHandler('handTool');	

		function onLButtonDown(event, data){			
			_bMovePage = true;
            _oldPosY = event.pageY; //当前鼠标位置
            _oldPosX = event.pageX; //当前鼠标位置			
			_self.setPageContainerCursor("fwr-catch-cursor");
			         
		}

		function onLButtonUp(event, data){
			if (_bMovePage) {   
				_self.setPageContainerCursor("fwr-hand-cursor");				
        	}
        	_bMovePage = false;
		}

		function onMouseMove(event, data) {
			if (!_bMovePage) return true;          
        	_self.pageContainer.trigger("movePage", [_oldPosX - event.pageX, _oldPosY - event.pageY]);
        	_oldPosY = event.pageY;
        	_oldPosX = event.pageX;
        	return true;
		}			

		_self
		.on('lbuttondown.pdf', onLButtonDown)
		.on('lbuttonup.pdf', onLButtonUp)
		.on('mousemove.pdf', onMouseMove);


		return _self;
	}]);
});